package com.example.administrator.kotlintutorial.`class`

/**
 * Created by chensuilun on 2019/2/21.
 */

class Empty

class MyFirstKtClass(name: String = "First Blood") {

    val firstProperty = "First property: $name".also(::println)

    init {
        //主构造函数的初始化块
        println("MyFirstKtClass.$name")
    }

    val secondProperty = "Second property: ${name.length}".also(::println)

    init {
        println("Second initializer block that prints ${name.length}")
    }

    //每个次构造函数需要委托给主构造函数(如果定义了的话)
    constructor(name: String, age: Int) : this(name)
}

fun main() {
    val myFirstKtClass = MyFirstKtClass("XiaoMing", 19)
}